package com.hm.service.api.upload;

import com.hm.service.service.upload.UploadPictureService;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping(value = "/UPLOAD", produces = {"application/json;charset=UTF-8"})
public class SZCG_001_000_001 {

    private static final Logger logger = LoggerFactory.getLogger(SZCG_001_000_001.class);


    private final UploadPictureService uploadPictureService;

    //图片上传接口
    public SZCG_001_000_001(UploadPictureService uploadPictureService) {
        this.uploadPictureService = uploadPictureService;
    }

    @PostMapping(value = "/001_000_001")
    //参数名需要与form表单中设置的 name属性值对应上，否则获取到的为null
    public String doPost(MultipartFile file, HttpServletRequest request) {
        String permit = request.getHeader("permit");
        return uploadPictureService.uploadPic(file, permit);
    }


}
